module.exports = Behavior({
    showWhiteHead: false,
    custom_head: null,
    ready() {
        this.delay(() => {
            this.custom_head = this.selectComponent('#custom_head')
        }, 50)
    },
    methods: {
        onPageScroll({ scrollTop }) {
            if (scrollTop <= 0) {
                this.custom_head.setWhiteBar(false)
                wx.setNavigationBarColor({
                    frontColor: '#ffffff',
                    backgroundColor: '',
                    animation: {
                        duration: 400,
                        timingFunc: 'easeIn'
                    }
                })
                return this.showWhiteHead = false
            }
            if (!this.showWhiteHead) {
                this.custom_head.setWhiteBar(true)
                this.showWhiteHead = true
                wx.setNavigationBarColor({
                    frontColor: '#000000',
                    backgroundColor: '',
                    animation: {
                        duration: 400,
                        timingFunc: 'easeIn'
                    }
                })
            }
        }
    }
})